package com.nbsaas.boot.manufacturing.data.entity;

import com.nbsaas.boot.code.annotation.*;
import com.nbsaas.boot.jpa.data.entity.AbstractEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import lombok.Data;
import org.hibernate.annotations.Comment;

import java.math.BigDecimal;
import java.util.Date;

@CreateByUser
@ComposeView
@Data
@FormAnnotation(title = "设备", model = "设备")
@Entity
@Table(name = "bs_equipment")
@Comment("设备表")
public class Equipment extends AbstractEntity {

    @Comment("设备编码")
    @SearchItem(name = "equipmentCode", key = "equipmentCode", label = "设备编码")
    @FormField(title = "设备编码", sortNum = "1", grid = true, required = true)
    @Column(length = 50, nullable = false, unique = true)
    private String equipmentCode;

    @Comment("设备名称")
    @SearchItem(name = "name", key = "name", label = "设备名称")
    @FormField(title = "设备名称", sortNum = "2", grid = true, required = true)
    @Column(length = 200, nullable = false)
    private String name;

    @Comment("设备型号")
    @FormField(title = "设备型号", sortNum = "3", grid = true)
    @Column(length = 100)
    private String model;

    @Comment("设备类型")
    @FormField(title = "设备类型", sortNum = "4", grid = true, type = InputType.select)
    @Column(length = 50)
    private String equipmentType; // MACHINE-机床, TOOL-工具, MEASUREMENT-测量设备, TRANSPORT-运输设备

    @Comment("设备分类")
    @FormField(title = "设备分类", sortNum = "5", grid = true, type = InputType.select)
    @Column(length = 50)
    private String equipmentCategory; // CNC-数控机床, LATHE-车床, MILLING-铣床, DRILLING-钻床

    @Comment("所属工作中心ID")
    @FormField(title = "所属工作中心", sortNum = "6", grid = true, type = InputType.select)
    private Long workCenterId;

    @Comment("制造商")
    @FormField(title = "制造商", sortNum = "7", grid = true)
    @Column(length = 200)
    private String manufacturer;

    @Comment("供应商")
    @FormField(title = "供应商", sortNum = "8", grid = true)
    @Column(length = 200)
    private String supplier;

    @Comment("设备状态")
    @FormField(title = "设备状态", sortNum = "9", grid = true, type = InputType.select)
    @Column(length = 20)
    private String status; // RUNNING-运行, IDLE-空闲, MAINTENANCE-维护, REPAIR-维修, RETIRED-报废

    @Comment("设备描述")
    @FormField(title = "设备描述", sortNum = "10", type = InputType.richText, col = 23)
    @Column(length = 1000)
    private String description;

    @Comment("技术规格")
    @FormField(title = "技术规格", sortNum = "11", type = InputType.richText, col = 23)
    @Column(columnDefinition = "TEXT")
    private String technicalSpecifications;

    @Comment("设备参数")
    @FormField(title = "设备参数", sortNum = "12", type = InputType.richText, col = 23)
    @Column(columnDefinition = "TEXT")
    private String equipmentParameters;

    @Comment("生产能力(件/小时)")
    @FormField(title = "生产能力(件/小时)", sortNum = "13", grid = true, type = InputType.el_input_number)
    private Integer productionCapacity;

    @Comment("设备精度")
    @FormField(title = "设备精度", sortNum = "14", grid = true)
    @Column(length = 100)
    private String accuracy;

    @Comment("设备尺寸")
    @FormField(title = "设备尺寸", sortNum = "15", grid = true)
    @Column(length = 100)
    private String dimensions;

    @Comment("设备重量(千克)")
    @FormField(title = "设备重量(千克)", sortNum = "16", grid = true, type = InputType.el_input_number)
    private Integer weight;

    @Comment("功率(千瓦)")
    @FormField(title = "功率(千瓦)", sortNum = "17", grid = true, type = InputType.el_input_number)
    private BigDecimal power;

    @Comment("电压(伏)")
    @FormField(title = "电压(伏)", sortNum = "18", grid = true, type = InputType.el_input_number)
    private Integer voltage;

    @Comment("电流(安)")
    @FormField(title = "电流(安)", sortNum = "19", grid = true, type = InputType.el_input_number)
    private BigDecimal current;

    @Comment("设备图片")
    @FormField(title = "设备图片", sortNum = "20", type = InputType.image)
    @Column(length = 500)
    private String image;

    @Comment("购买日期")
    @FormField(title = "购买日期", sortNum = "21", type = InputType.date, grid = true)
    private Date purchaseDate;

    @Comment("购买价格")
    @FormField(title = "购买价格", sortNum = "22", grid = true, type = InputType.el_input_number)
    @Column(precision = 10, scale = 2)
    private BigDecimal purchasePrice;

    @Comment("预计使用年限")
    @FormField(title = "预计使用年限", sortNum = "23", grid = true, type = InputType.el_input_number)
    private Integer expectedLife;

    @Comment("折旧方法")
    @FormField(title = "折旧方法", sortNum = "24", grid = true, type = InputType.select)
    @Column(length = 50)
    private String depreciationMethod; // STRAIGHT_LINE-直线折旧, DECLINING_BALANCE-余额递减

    @Comment("年折旧率(%)")
    @FormField(title = "年折旧率(%)", sortNum = "25", grid = true, type = InputType.el_input_number)
    @Column(precision = 5, scale = 2)
    private BigDecimal annualDepreciationRate;

    @Comment("累计折旧")
    @FormField(title = "累计折旧", sortNum = "26", grid = true, type = InputType.el_input_number)
    @Column(precision = 10, scale = 2)
    private BigDecimal accumulatedDepreciation;

    @Comment("设备净值")
    @FormField(title = "设备净值", sortNum = "27", grid = true, type = InputType.el_input_number)
    @Column(precision = 10, scale = 2)
    private BigDecimal netValue;

    @Comment("负责人")
    @FormField(title = "负责人", sortNum = "28", grid = true)
    private Long manager;

    @Comment("维护周期(天)")
    @FormField(title = "维护周期(天)", sortNum = "29", grid = true, type = InputType.el_input_number)
    private Integer maintenanceCycle;

    @Comment("上次维护日期")
    @FormField(title = "上次维护日期", sortNum = "30", type = InputType.date, grid = true)
    private Date lastMaintenanceDate;

    @Comment("下次维护日期")
    @FormField(title = "下次维护日期", sortNum = "31", type = InputType.date, grid = true)
    private Date nextMaintenanceDate;

    @Comment("维护要求")
    @FormField(title = "维护要求", sortNum = "32", type = InputType.richText, col = 23)
    @Column(columnDefinition = "TEXT")
    private String maintenanceRequirements;

    @Comment("安全要求")
    @FormField(title = "安全要求", sortNum = "33", type = InputType.richText, col = 23)
    @Column(columnDefinition = "TEXT")
    private String safetyRequirements;

    @Comment("操作手册")
    @FormField(title = "操作手册", sortNum = "34", type = InputType.richText, col = 23)
    @Column(columnDefinition = "TEXT")
    private String operationManual;

    @Comment("备注")
    @FormField(title = "备注", sortNum = "35", type = InputType.richText, col = 23)
    @Column(length = 1000)
    private String note;
} 